<h2>Comments moderation</h2>
<div class="comments">
<form method="post" action="<?php echo $t['submit_route'];?>">
<input type="hidden" name="action_type" value="mass-delete"/>
<?php $return_link = $ro->gen('comment.moderation', array(), array('relative'=>FALSE)); ?>
<?php foreach ($t['comments'] as $c):?>
<?php 
    $name = htmlspecialchars($c['name']);
    if ($c['is_user']) {
        $img = '';
        if ($c['type'] === 'openid') {
            $img = '<img src="images/openid_icon.png" class="openid" />';
        }
        $name = sprintf('<a href="" onclick="return false;">%s%s</a>', $img, $name);
    }

    $website = htmlspecialchars($c['website']);
    
    $service_links = array();
    $service_links[] = sprintf('<a href="%s">[delete]</a>', 
        $ro->gen('comment.delete', array('comment_id'=>$c['id'], 'return_url'=>$return_link)));
    $service_links[] = sprintf('<a href="%s">[approve]</a>', 
        $ro->gen('comment.approve', array('comment_id'=>$c['id'], 'return_url'=>$return_link)));
    $service_links[] = sprintf('<a href="%s">[link]</a>', $c['comment_url']);
?>
<div class="comment-hidden">
<div class="title"><label><input type="checkbox" name="comments[]" value="<?php echo $c['id']; ?>" id="c_c_<?php echo $c['id']; ?>"/> select</label> <?php echo implode(' ', $service_links);?></div>
<div class="title"><strong>Name</strong>: <?php echo $name; ?>
</div>
<div class="title"><strong>Time</strong>: <?php echo $c['time']; ?>
</div>
<div class="title"><strong>Website</strong>: <?php echo $website; ?>
</div>

<div class="body">
<?php 
$full = MarkupProcessor::renderCommentText($c['text']);
$short = null;

// TODO: replace 100 with the value taken from settings
if (mb_strlen($c['text'], 'utf-8') > 50) {
    $short = htmlspecialchars(mb_substr($c['text'], 0, 50, 'utf-8'));
}
?>
<div id="c_f_<?php echo htmlspecialchars($c['id']);?>" style="<?php if (!is_null($short)) { echo 'display: none';} ?>">
<?php echo $full; ?>
</div>


<?php if (!is_null($short)):?>
<div id="c_s_<?php echo htmlspecialchars($c['id']);?>">
<?php echo $short; ?>…<a href="" onclick="hide_element('c_s_<?php echo htmlspecialchars($c['id']);?>'); show_element('c_f_<?php echo htmlspecialchars($c['id']);?>', 'block'); return false;">more</a>
</div>
<?php endif;?>

</div>
</div>
<?php endforeach;?>
<div><input type="submit" value="delete selected"/></div>
</form>
</div>
